package com.company.controller;

import com.company.dao.Fooddao;
import com.company.dao.Userdao;
import com.company.dao.impl.Fooddaoimpl;
import com.company.dao.impl.Userdaoimpl;
import com.company.entity.Food;
import com.company.entity.User;


import java.awt.*;
import java.lang.reflect.Array;
import java.sql.SQLException;
import java.util.*;
import java.util.List;

public class ELDCENTERCONTROLLER<sign> {
    public static void main(String[] args) throws SQLException {

        boolean sign = true;
        Scanner sc = new Scanner(System.in);
        do {
            System.out.println("*******欢迎来的颐养系统********");
            System.out.println("1.菜品管理");
            System.out.println("2.用户管理");
            System.out.println("3.床位管理");
            System.out.println("4.客人管理");
            System.out.println("5.退出系统");
            System.out.println("请选择：");
            int num = sc.nextInt();
            switch (num) {
                case 1:
                    boolean flag = true;
                    do {
                        System.out.println("1.添加菜品");
                        System.out.println("2.修改菜品");
                        System.out.println("3.删除菜品");
                        System.out.println("4.查询菜品");
                        System.out.println("5.回到上一级目录");
                        int chose = sc.nextInt();
                        switch (chose) {
                            case 1:

                                Fooddaoimpl p1 = new Fooddaoimpl();
                                p1.addFood();

                                break;

                            case 2:


                                Fooddaoimpl p = new Fooddaoimpl();
                                p.upFood();


                                break;
                            case 3:
                                Food food3 = new Food();
                                System.out.println("请输入删除的菜品id");
                                food3.setId(sc.nextInt());
                                Fooddao fooddao3 = new Fooddaoimpl();
                                fooddao3.delFoodbID(food3);
                                break;

                            case 4:
                                Fooddao fooddao4 = new Fooddaoimpl();
                               // System.out.println(fooddao4.Findall());
                                List<Food> lis = new ArrayList<Food>();
                                      lis =  fooddao4.Findall();
                                      for (Food s:lis){
                                          System.out.println(s);
                                      }

                            case 5:
                                flag = false;
                                System.out.println("退出系统！");
                                break;
                            default:
                                System.out.println("先择不存在重新选择");
                                break;
                        }

                    } while (flag);
                    break;
                case 2:
                    boolean flag1 = true;
                    do {
                        System.out.println("1.添加用户");
                        System.out.println("2.修改用户");
                        System.out.println("3.删除用户");
                        System.out.println("4.查询用户");
                        System.out.println("5.回到上一级目录");
                        int chose = sc.nextInt();
                        switch (chose) {
                            case 1:
                                Userdaoimpl us = new Userdaoimpl();
                                us.adduser();

                                break;

                            case 2:


                              Userdaoimpl us1 = new Userdaoimpl();
                              us1.upuser();


                                break;
                            case 3:
                                User user = new User();
                                System.out.println("请输入要删除的id");
                                user.setId(sc.nextInt());
                                Userdao userdao = new Userdaoimpl();
                                      boolean bl  = userdao.delUserid(user);
                                      if(bl){
                                          System.out.println("删除成功");
                                      }else {
                                          System.out.println("删除失败");
                                      }
                                break;

                            case 4:
                                Userdao userdao2 = new Userdaoimpl();
                                System.out.println(userdao2.findall());



                            case 5:
                                flag1 = false;
                                System.out.println("退出系统！");
                                break;
                            default:
                                System.out.println("先择不存在重新选择");
                                break;
                        }

                    } while (flag1);

                            break;
                        case 3:

                            break;
                        case 4:
                            break;
                        case 5:

                            sign = false;
                            System.out.println("退出系统！");
                            break;
                        default:
                            System.out.println("先择不存在重新选择");
                            break;


                    }

            }while (sign) ;

        }


    }

